package com.spzx.product.api;

import com.spzx.common.core.constant.ServiceNameConstants;
import com.spzx.common.core.domain.R;
import com.spzx.common.core.web.page.TableDataInfo;
import com.spzx.product.api.factory.RemoteProductFallbackFactory;
import com.spzx.product.domain.SkuPriceDTO;
import com.spzx.product.domain.SkuStockDTO;
import com.spzx.product.domain.vo.IndexVO;
import com.spzx.product.domain.ProductSku;
import com.spzx.product.domain.SkuQuery;
import com.spzx.product.domain.vo.ProductSkuDetailsVO;
import io.swagger.v3.oas.annotations.Operation;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.cloud.openfeign.SpringQueryMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;

import java.util.List;

//商品模块远程调用客户端
@FeignClient(value = ServiceNameConstants.PRODUCT_SERVICE, //PRODUCT_SERVICE常量，值为 spzx-product
             fallbackFactory = RemoteProductFallbackFactory.class)
public interface RemoteProductService {


    @Operation(summary = "内部调用接口：提交订单验证库存")
    @PostMapping("product/checkSkusStock")
    public R<List<SkuStockDTO>> checkSkusStock(@RequestBody List<SkuStockDTO> skuStockDTOs);

    @Operation(summary = "内部调用接口：提交订单验证价格")
    @PostMapping("product/checkSkusPrice")
    public R<List<SkuPriceDTO>> checkSkusPrice(@RequestBody List<SkuPriceDTO> skuPriceDTOS);


    @Operation(summary = "内部调用接口：根据skuid查询购物的商品详情")
    @GetMapping("product/getSku/{skuId}")
    public R<ProductSku> getSkuById(@PathVariable("skuId") long skuId);



    //PRODUCT_SERVICE : 代表服务的地址
    //product/listIndexVO : 代表资源路径
    // http://xxx:9204/product/listIndexVO
    @Operation(summary = "内部调用接口：查询首页热门数据")
    @GetMapping("product/listIndexVO")
    public R<IndexVO> listIndexVO();
    //    @Operation(summary = "内部调用接口：查询首页热门数据")
    //    @GetMapping("product/listIndexVO")
    //    public R<IndexVO> listIndexVO(
    //            //调用时传入的参数 会当作请求头配置(from-source: 实参值)
    //            @RequestHeader(SecurityConstants.FROM_SOURCE)
    //                                      String source);
    //http://xxx:9204/category/listCatesTree
    //    @Operation(summary = "内部调用接口：查询分类树")
    //    @GetMapping("category/listCatesTree")
    //    public R<List<Category>> listCatesTree(@RequestHeader(SecurityConstants.FROM_SOURCE)
    //                                               String source);
    //查询

    @GetMapping("product/skuList")
    public R<TableDataInfo> skuList(@SpringQueryMap SkuQuery skuQuery);

    @Operation(summary = "内部调用接口：根据id查询sku详情")
    @GetMapping("product/getSkuDetailsVO/{skuId}")
    public R<ProductSkuDetailsVO> getSkuDetailsVO(@PathVariable("skuId")
                                                  Long skuId);
}